<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /**
     * arr.splice(删除数组元素的索引位置，被删除元素的个数，新添加的元素)
     * 从指定的索引位置删除指定个数的数组元素arr.spilce(index,number)
     * arr.splice(index,0,"新元素")在指定的索引位置上添加新的元素
     * 前俩个参数是必须参数，后面参数可选
     * 返回值是被删除的元素组成的新数组
    */
    //删除元素，不是头删也不是尾删
    var userList = ["zhangsan","lisi","wusiqi","wangwu","zhaoliu"];
    var index = userList.indexOf("wusiqi");
    var result = userList.splice(index,2);
    console.log(result);
    console.log(userList);

    userList.splice(1,0,"fengkeyi","zhaosi");
    console.log(userList);
</script>
</html>